<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>p2_CSS选择器</title>
</head>
    <style>
        h4{
            color: red;
        }
        div{
            width: 100px;
            height: 100px;
            background-color: yellow;
        }
        #d2{
            border: 5px solid black;
            color: red;
        }
        .error{
            color: red;
            background-color: red;
        }
        .success{
            color: green;
            background-color: green;
        }
        .msg{
            color: white;
        }
        #d2,h4,.error{
            text-decoration: underline;
        }
        *{
            font-style: italic;
        }
        input[type="text"]{
            background-color: red;
        }
        a:link{
            color: gray;
        }
        a:visited{
            color: green;
        }
        a:hover{
            color: orange;
        }
        a:active{
            color: red;
        }
        div span{
            color: orange;
        }
        #d1>div>span{
            color: red;
        }


    </style>
<body>
<div id="1">
    <div id="d1">
        <span>1</span>
        <div>
            <span>2</span>
            <p>测试文字</p>
            <p>我是<span>测试</span>段落</p>
        </div>
        <span>3</span>
    </div>


      <h4>我是标题</h4>
      <p>我是段落</p>
      <a href="https://www.baidu.com">我是超链接1</a>
      <a href="abc">我是超链接2</a>
      <a href="#">我是超链接</a>
      <hr>
      <h4 id="d2">我是标题2</h4>
      <div>我是div1</div>
      <div>我是div2</div>
      <div>我是div4</div>
      <hr>
      <span class="error msg">用户名已被占用</span>
      <span class="error msg">密码长度不正确</span>
      <span class="error msg">手机号格式不正确</span>
      <br>
      <span class="success msg">用户名已经可以使用</span>
      <span class="success msg">密码为合法密码</span>
      <span class="success msg">手机号未被注册</span>
      <hr>
      <input type="text">
      <input type="password">
</body>
</html>